Skip to content

Record serve daemon transition worksheets and baselines - #758

Merged
sambitcreate merged 60 commits into
mainfrom
feature/sm-serve-daemon
Nov 6, 2026
Merged

sambitcreate merged 60 commits into
mainfrom
feature/sm-serve-daemon

Conversation

@sambitcreate

@sambitcreate sambitcreate commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

The Lane D stack for aiden serve, folded into this root. #759 to #765 merged into this branch, so this PR now carries the whole stack: the transition worksheet and baselines, explicit daemon turn ownership, shared approval coordination, serve lifetime and ownership, bounded control framing, deletion recovery, and schedule consent.

  • Inventory: cli-native C09, C10, C03, C01, C02, C11, C04
  • Tests: packages/cli/tests/daemon-turns.test.mjs, tests/serve-lifetime.test.mjs and the stack's other behavioral suites

Shared contracts: no persistence, wire-format, protocol revision, telemetry, network or runtime-flag change. Nothing outside packages/cli, docs/state-machines and .memory changed, so the iOS and Android suites were not run.

Worksheet: docs/state-machines/serve-daemon.md.

Flake record (local, no CI run): durable CLI Bots can message each other in the CLI parity suite failed once on its 10s deadline, at host load of about 14. Its ledger showed the reply en route. It passed alone and in the later full run of 250 tests (247 pass, 3 skipped). The same run's aiden.json settings failure was a fresh-worktree gap (build/native missing), not a flake. No timeout was changed.

🤖 Generated with Claude Code

sambitcreate and others added 21 commits November 4, 2026 19:26
Worksheets for cli-native C09, C10, C11, C03, C01, C02 and C04, with new
oracles for daemon turns and tool approval over a scripted provider, and
real-process serve lifetime and framing cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DaemonTurnOwner becomes the single writer of per-chat custody (lease,
settling, generation) and daemon intake, replacing the reserved set, active
map and closed flag. DaemonGenerationRun separates stop request, terminal
persistence and physical release. Public llmClient behavior is unchanged
apart from three reproduced fixes:

- stop() now waits for revoked work whose append is still in flight.
- A stop during a Bot authority check no longer lets the prompt or tool run.
- A failed session-lease removal no longer hangs idle waiters and shutdown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ServeLifetime makes the control socket's phase explicit and tracks accepted
commands. Shutdown previously destroyed a running command's client and
released the lease under it, so the client saw a closed connection while the
command kept changing state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The abort signal was read only after every startup step had finished, so the
socket kept taking commands and ready still fired. A signal now drains the
socket at once and skips the remaining steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A throwing activity listener skipped the journal and session-lease steps while
idle waiters were told the run had released. A run that failed to register
held its chat and shutdown forever. Each cleanup step now runs on its own, and
a failed registration gives the chat back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
serve-ownership.ts holds what stop may do at its start and its deadline.
A PID that stopped being ours just before the deadline used to end in
'did not stop, try kill -9 <pid>', pointing at an unrelated process. It now
clears the stale lease, and a changed owner counts as stopped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Remote status read could take a signal, and ready still fired after it.
The daemon tests also orphaned their servers: cleanup hooks run in order, so
the directory was gone before `serve stop` could find the server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A chunk that crossed 8 MiB and also carried the newline destroyed the socket
and then still parsed and returned the reply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both ends parsed the whole buffer, so the outcome of a request depended on how
its bytes were split into chunks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
daemon-approvals.ts adapts ToolApprovalCoordinator, which already owns one-shot
settlement, owner scoping and abort, instead of a second hand-written pending
map. Only the expiry, approval id and journal decision stay daemon-specific.
A prompt that cannot be delivered now fails closed and withdraws its attention.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tombstone replay lived in createCliRemoteChats, so aiden serve --no-remote
neither completed a committed deletion nor closed that chat to new turns.
The daemon now closes tombstoned chats at construction and recovery runs at
serve startup. A failure closes only those chats.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Trailing bytes in the same chunk could push a frame that fit over its ceiling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A save read its file after consent without comparing it to what was reviewed,
and new-task consent stayed valid until expiry because only the retired
producer removed its receipt. No caller in src produces consent today, so
this hardens the guard that remains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The in-memory spent list covers one scheduler. Separate offline commands build
their own, so a receipt left on disk could be replayed through a new one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At the deadline, a live PID classified as another Aiden command or as
unverifiable fell through to the message that called it the daemon and
recommended kill -9. It now reports that the stop is unconfirmed and keeps
the lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The baseline suite can orphan a background daemon, and several assertions do not independently enforce the transitions they claim to preserve.

Reviewed changes I reviewed all five files in the initial Lane D baseline commit.

  • Transition worksheets — Documents the current C01, C02, C03, C04, C09, C10, and C11 owners, states, guards, effects, and linearization points.
  • Daemon turn baselines — Adds built-CLI behavioral coverage for admission, generation persistence and cancellation, resource release, and tool approvals.
  • Serve lifetime baselines — Adds real-process coverage for daemon ownership, startup and shutdown cleanup, and control-socket framing and client outcomes.
  • Test registration and migration context — Registers both suites in the CLI test command and records Lane D implementation context in project memory.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏

sambitcreate and others added 8 commits November 4, 2026 20:32
socket.end() returns before queued bytes leave, so shutdown could destroy a
client mid-reply. A slow reader received a truncated response.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The client kept buffering after its reply, so a peer that kept writing could
grow its memory and hold its socket open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A malformed record was logged and treated as no pending deletions, so a chat
whose deletion had committed could reopen. Remote used to reject this state.
Every chat now stays closed and no server starts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sambitcreate and others added 2 commits November 4, 2026 20:40
The timeline projector had already closed as completed, so chat:error and the
retried message both claimed a completed turn. Both now say failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new assertion is correct and introduces no new issue, but three must-address findings from the prior review remain open.

Reviewed changes I reviewed the approval-attention test correction added since the prior Pullfrog review.

  • Strengthened approval attention baseline — Replaced the ineffective fallback assertion with an exact check of the real approvalChatIds snapshot field and expected chat ID.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix it ➔ | View workflow run | Using GPT Sol | 𝕏

sambitcreate and others added 22 commits November 4, 2026 20:44
Cleanup inside the publish callback could journal cancelled for an approval
that settled allowed, and a publish that settled its own prompt was never
withdrawn. The adapter now reports once, from the settled outcome.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The receipt survived until the command returned, so a process that died after
publishing left it for a new scheduler to replay. It is now removed just
before the first write publishes. Adds coverage of the follow-on phase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Forced removal hid a receipt deleted just after the last check, so the write
still published. A missing receipt now stops it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onsent

Give schedule consent one phase and bind it to the review
Finish interrupted chat deletions on every server
Move daemon tool approval onto the shared coordinator
Keep the serve lease until accepted commands settle
Make daemon chat custody and generation settlement explicit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes I reviewed the integrated Lane D production stack and follow-up corrections added since the prior Pullfrog baseline review.

  • Explicit daemon turn ownership — Added single-writer custody, generation settlement, stop, persistence, cleanup, capacity, and idle transitions with behavioral race coverage.
  • Shared approval coordination — Moved daemon tool prompts onto ToolApprovalCoordinator and made each raised prompt's one-shot journal outcome match its actual settlement.
  • Serve lifetime and ownership — Added startup cancellation checks, accepted-command draining through reply flush, and process-owner revalidation before forced signals.
  • Bounded control framing — Made both socket ends consume one newline-delimited frame, enforce frame-local byte ceilings, and disconnect peers after the first answer.
  • Deletion recovery — Gated tombstoned chats from construction through durable recovery and ran recovery before every server exposes Remote or local turn ingress.
  • Schedule consent — Bound saves to reviewed input, consumed receipts at first publication, and covered replay, revocation, environment, and follow-on-write behavior.
  • Worksheets and baselines — Expanded the state-machine worksheet, CLI documentation, project memory, parity exports, and three focused suites for the integrated behavior.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏

@sambitcreate
sambitcreate merged commit 963acf3 into main Nov 6, 2026
26 checks passed
@sambitcreate
sambitcreate deleted the feature/sm-serve-daemon branch November 6, 2026 13:36
sambitcreate added a commit that referenced this pull request Nov 6, 2026
The daemon's hook ask now goes through the #758 approval coordinator, and
its Stop loop reads the run's stop state. The hooks socket command stays
in the lifetime-tracked handler.

Remote clips an approval summary at 2,000 characters, so a hook reason
placed ahead of a long tool request could cut off the request's end. The
reason now follows the tool, as it does on the desktop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant